# 认证装饰器
import time
user_list=[
{"username":'张三','password':'123456'},
{"username":'李四','password':'123456'},
{"username":'王二','password':'123456'},
{"username":'赵武','password':'123456'},
{"username":'孙六','password':'123456'},
{"username":'萌萌','password':'123456'}]

curruct_dict={"username":None,'login':False}

def autho_fun(func):
    def wrapper(*args,**kwargs):
        if curruct_dict["username"] and curruct_dict['login']:
            res=func(*args,**kwargs)
            return res
        username = input('用户名').strip()
        password =input('密码').strip()
        for user_dict in user_list:
            if username==user_dict['username'] and password==user_dict['password']:
                curruct_dict['username']=username
                curruct_dict['login'] = True
                res = func(*args, **kwargs)
                return res
        else:
            print('用户名或密码错误')
    return wrapper
@autho_fun
def home(name):
    time.sleep(2)
    print('%s，欢迎登陆京东商城'% name)

@autho_fun
def shopcar(name):
    time.sleep(2)
    print('%s的购物车里有奶茶妹妹' % name)
@autho_fun
def order(name):
    time.sleep(2)
    print('%s ，请确认你的订单'% name)

home('萌萌')
shopcar('萌萌')
order('萌萌')